<template>
  <el-dialog :visible.sync="dialog.visible"
             :title="dialog.title"
             width="60%"
             :close="close">
    <avue-form v-if="formOption" :option="formOption" v-model="formModel"></avue-form>
  </el-dialog>
</template>
<script>


import formDataApi from "@/api/start/formEngine/formDataApi";
import actCloudFormApi from "@/api/start/formEngine/formApi";
import avueDataAdapter from "utils/avueDataAdapter";
import startActFormTools from "@/views/start/activiti/components/startActFormTools";

export default {
  name: "formDetailDialog",
  data() {
    return {
      dialog: {
        visible: false,
        title: "",
      },
      formOption: null,
      formModel: {},
      tableId: null,
      dataId: null,
    }
  },
  methods: {
    show(row) {
      this.dialog.title = row.tableNameCN + "详情"
      this.tableId = row.tableId;
      this.dataId = row.dataId;
      formDataApi.getById(this.tableId, this.dataId).then(res => {
        this.formModel = res.data
        return actCloudFormApi.getTableOption(this.tableId)
      }).then(res => {
        this.analysisTable(res.data)
        this.dialog.visible = true
      })

    },

    analysisTable(formConfig) {
      formConfig.formOption.detail = true
      formConfig.formOption.boxType = "detail"
      formConfig.formOption.submitBtn = false;
      formConfig.formOption.emptyBtn = false;
      formConfig.formOption.menuBtn = false;
      startActFormTools.autoActMainForm(formConfig.formOption)
      avueDataAdapter.transformDataList(formConfig.formOption.column, this.formModel)
      this.formOption = formConfig.formOption
    },
    close() {
      this.dialog.visible = false;
      this.dialog.title = ""
      this.formOption = null
      this.formId = null;
      this.formModel = {}
    }
  }
}
</script>
<style scoped lang="scss">

</style>
